import request from '@/utils/request';

// 软件是否具备更新能力
export async function updateVersionApi(params) {
  const res = await request.get('massage/updatedVersion/updateVersion', {
    params
  });

  if (res.data.code === 200) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.msg));
}

//登录验证是否是盗版站点
export async function selectPiratesite() {
  const res = await request.get('massage/updatedVersion/selectPiratesite');
  if (res.data.code === 200) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.msg));
}

// 查询版本列表

export async function selectRenewInfo(data) {
  const res = await request.post(
    'https://c11.weijuyunke.cn/javaAccredit/empowerrenew/selectRenewInfo',
    data
  );

  if (res.data.code === 2000) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.msg));
}

// 版本更新按钮
export async function fileDownload(data) {
  const res = await request.post('massage/updatedVersion/fileDownload', data);

  if (res.data.code === 200) {
    return res.data.message;
  }
  if (res.data.code === 500) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.msg));
}

// 查询当前的登入的是账号是主站的还是子站点

export async function getUserRoleName(data) {
  const res = await request.post('/api/system/user/getUserRoleName', data);

  if (res.data.code === 200) {
    if (res.data.data) {
      return res.data.data;
    } else {
      return undefined;
    }
  }
  return Promise.reject(new Error(res.msg));
}
